package com.fsm.system.entity;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mybatisflex.annotation.*;

import java.io.Serializable;
import java.util.Date;

import com.mybatisflex.core.keygen.KeyGenerators;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

/**
 *  实体类。
 *
 * @author 翻山鸣
 * @since 2024/04/20
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "系统用户管理")
@Table("t_system_user")

public class TSystemUser implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 用户id
     */
    @ExcelProperty("用户id")
    @Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
    @Schema(description = "用户id")
    private String id;

    /**
     * 角色id
     */
    @Schema(description = "角色ID")
    private String roleId;

    /**
     * 角色信息
     */
    @RelationOneToOne(selfField = "roleId",targetField = "id")
    @Column(ignore = true)
    @Schema(description = "角色")
    private TSystemRole role;

    /**
     * 登录名
     */
    @ExcelProperty("登录名")
    @Schema(description = "登录名")
    private String loginName;

    /**
     * 密码
     */
    @Schema(description = "密码")
    private String password;

    /**
     * 头像
     */
    @Schema(description = "头像")
    private String head;

    /**
     * 联系电话
     */
    @Schema(description = "联系电话")
    private String phone;

    /**
     * 过期时间
     */
    @Schema(description = "过期时间")
    private String expirationTime;

    /**
     * 姓名
     */
    @Schema(description = "姓名")
    private String name;

    /**
     * 公司名
     */
    @Schema(description = "公司名")
    private String companyName;

    /**
     * 租户ID
     */
    @Column(value = "tenant_id",tenantId = true)
    @Schema(description = "租户ID")
    private String tenantId;

    /**
     * 创建时间
     */
    @ExcelProperty("创建时间")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(value = "create_time",onInsertValue = "now()")
    @Schema(description = "创建时间")
    private Date createTime;

    /**
     * 修改时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(value = "update_time",onUpdateValue = "now()")
    @Schema(description = "修改时间")
    private Date updateTime;

    @Column(ignore = true)
    @Schema(description = "token")
    private String token;

    /**
     * 存在
     */
    @Column(value = "exist",onInsertValue = "1",isLogicDelete = true)
    @Schema(description = "存在")
    private Integer exist;

    @Column(ignore = true)
    @Schema(description = "页数")
    private Integer page;

    @Column(ignore = true)
    @Schema(description = "条数")
    private Integer limit;


}
